#pragma once
#include <osg/PrimitiveSet>

#include "Ent.h"

class TopoDS_Face;
class JsonReader;

struct SurfacePrivate;
class Surface : public Ent3DFace
{
	Q_OBJECT
public:
	Surface(INode* parent);
	void setShape(const TopoDS_Face& shape);
	const TopoDS_Face& shape() const;
	virtual void update3D() override;
	virtual osg::Node* getRep3D() const override;
	virtual void setSelected(bool val) override;
	virtual void save(QJsonObject &json) const;
	virtual void load(const QJsonObject& json, JsonReader& reader);
	virtual void move(const osg::Vec3d& offset) override;
	virtual std::vector<osg::Vec3d> handles() const override;
	virtual std::vector<std::vector<osg::Vec3d>> getEdgePoints() const override;
	virtual std::shared_ptr<Ent> clone() const override;
	virtual void copy(const Ent& ent) override;
	virtual void reverse();
	virtual void updateColor();
	virtual void rotate(const double angle, const osg::Vec2d& basePoint) override;
	LEAF_METHODS;

protected:
	void updateEdgePoints();
	void calHandles() const;

	SurfacePrivate* d_ptr;
};